repos:
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v4.4.0
    hooks:
      - id: check-symlinks
      - id: destroyed-symlinks
      - id: trailing-whitespace
      - id: end-of-file-fixer
      - id: check-yaml
      - id: check-toml
      - id: check-ast
      - id: check-added-large-files
      - id: check-merge-conflict
      - id: check-executables-have-shebangs
      - id: check-shebang-scripts-are-executable
      - id: detect-private-key
      - id: debug-statements

  - repo: https://github.com/astral-sh/ruff-pre-commit
    rev: v0.1.3
    hooks:
      - id: ruff
        files: '^python/.*'
        args: ["--fix", "--line-length", "120"]
        stages: [commit, push, manual]
        exclude: |
          (?x)(
            ^python/triton/runtime/.*|
            ^test/|
            ^docs/conf.py$
          )

  - repo: https://github.com/google/yapf
    rev: be72557
    hooks:
      - id: yapf
        args: ["-p", "-i"]
        stages: [commit, push, manual]
        exclude: "python/test/unit/language/test_line_info.py"

  - repo: https://github.com/pre-commit/mirrors-clang-format
    rev: v16.0.6
    hooks:
      - id: clang-format
        stages: [commit, push, manual]

exclude: |
  (?x)(
    ^include/triton/external/|
    ^third_party/amd/backend/include/hip/|
    ^third_party/amd/backend/lib/|
    ^third_party/nvidia/backend/include/cuda.h
  )
